import instance from './request';

// 定义基础URL，与后端接口地址对应
const baseURL = 'http://172.20.10.10:3000';

export interface addFormInlineTS {
  username: string,
  phone: string,
  id: string,
  department: string,
  employeestype: string
}
const token =localStorage.getItem('token')

// 获取所有物料
export const getWu = () => {
  return instance.get(`http://172.20.10.10:3000/materials`);
};
// 添加物料
export const addWu = (data:any) => {
  return instance.post(`http://172.20.10.10:3000/materials`,data);
};
// 按多条件组合查询（示例：同时传姓名和部门）
export const queryUserByMultiConditions = ({ name, category,  status }:{name:string,category:string,status:string}) => {
  const obj={
    name,
    category,
    status
  }
    const params = new URLSearchParams(obj).toString();
  return instance.get(`${baseURL}/materials?${params}`,{
    headers: {
      Authorization: `Bearer ${token}`, // 使用已获取的Token
    },
  });
};
// 获取所有车辆
export const getChe = () => {
  return instance.get(`http://172.20.10.10:3000/vehicleManagement`);
};
// 添加车辆
export const addChe = (data:any) => {
  return instance.post(`http://172.20.10.10:3000/vehicleManagement`,data);
};
// 获取所有会议
export const gethui = () => {
  return instance.get(`http://172.20.10.10:3000/meeting`);
};
// 添加车辆
export const addhui = (data:any) => {
  return instance.post(`http://172.20.10.10:3000/meeting`,data);
};
// 按多条件组合查询（示例：同时传姓名和部门）
export const queryUserByChe = ({ plate, type,  status }:{plate:string,type:string,status:string}) => {
  const obj={
    plate,
    type,
    status
  }
    const params = new URLSearchParams(obj).toString();
  return instance.get(`${baseURL}/vehicleManagement?${params}`,{
    headers: {
      Authorization: `Bearer ${token}`, // 使用已获取的Token
    },
  });
};





